docs: explain how to use the Go 1.27 stdlib uuid package via overrides - #4599
Merged
Conversation
Go 1.27 added a uuid package to the standard library (#4590). Document the type overrides that map uuid columns to the new package today: uuid.UUID for non-nullable columns and *uuid.UUID for nullable ones, since the standard library has no NullUUID type. Verified against PostgreSQL 16 with generated code compiled under Go 1.27.0: both pgx/v5 (via its underlying-[16]byte wrapping) and database/sql (via the new uuid.UUID conversions in convertAssign and driver.DefaultParameterConverter) round-trip values and NULLs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N9jm9kAWEiXHxg3LGsNP4p
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Go 1.27 added a
uuidpackage to the standard library (#4590). This documents the type overrides that let users adopt it today, ahead of sqlc switching its default UUID type:Nullable columns map to
*uuid.UUIDsince the standard library has noNullUUIDtype. No code changes were needed: the override machinery already parses the stdlib import path, and the existing special-casing inimports.gosuppresses the hardcodedgithub.com/google/uuidimport whenever an override renders asuuid.UUID.Verified end-to-end against PostgreSQL 16 with the generated code compiled under go1.27.0, for both sql packages:
[16]bytewrap plans (TryFindUnderlyingTypeScanPlan/TryWrapFindUnderlyingTypeEncodePlan).driver.DefaultParameterConverterbindsuuid.UUIDparameters andconvertAssignscansstring/[]bytevalues intouuid.UUIDand*uuid.UUIDdestinations, withnilasNULL.Round-trips covered v4 and v7 UUIDs plus NULL and non-NULL nullable columns.
No endtoend testdata case is included because generated code importing the stdlib
uuidpackage requires Go 1.27+, and the testdata module builds under the repo's Go 1.26 toolchain.uuid[]array columns were not verified, so the docs make no claims about them.🤖 Generated with Claude Code
https://claude.ai/code/session_01N9jm9kAWEiXHxg3LGsNP4p
Generated by Claude Code